// Copyright 2019 orivil.com. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found at https://mit-license.org.

package models

import admin_sql "gitee.com/orivil/morgine/bundles/admin/sql"

type JsonData struct {
	ID   int
	Name string `gorm:"index"`
	Data string
}

func GetJsonData(name string) (data string) {
	jd := &JsonData{}
	admin_sql.Gorm().Where("name=?", name).First(jd)
	return jd.Data
}

func SetJsonData(name, data string) error {
	exist := &JsonData{}
	admin_sql.Gorm().Where("name=?", name).First(exist)
	exist.Name = name
	exist.Data = data
	return admin_sql.Gorm().Save(exist).Error
}
